package com.example.迭代器模式;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 汉堡店菜单
 */
public class PancakeHouseShop {

    /**
     * 菜单列表
     */
    List<Menu> menuItems;

    public PancakeHouseShop() {
        this.menuItems = new ArrayList<>();

        // 默认就放入菜单项
        addItem("可乐", 3d);
        addItem("汉堡", 13d);
        addItem("薯条", 8d);
        addItem("鸡翅", 5d);
    }

    public void addItem(String name, Double price) {
        Menu menu = new Menu(name, price);
        menuItems.add(menu);
    }

    // 产生迭代器
    public Iterator createIterator() {
        return new PancakeHouseMenuIterator(menuItems);
    }
}
